﻿//
// © Algobox Ltd - Benn Eichhorn
//
using Algobox.Objects.Finance.Orders;
using System;
using Algobox.Objects.Finance;

namespace Algobox.Feeds.Finance.Trading
{
    public interface ITradingFeedAdaptor
    {
        string FeedName { get; }
        bool IsStarted { get; }

        event Action OnTradingFeedShutdown;

        /// <summary>
        /// Start the trading adaptor
        /// </summary>
        /// <returns>True when the adaptor started successfully</returns>
        bool Start();

        /// <summary>
        /// Stops the trading adaptor
        /// </summary>
        void Stop();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="order"></param>
        /// <param name="callback"></param>
        /// <param name="message"></param>
        /// <returns>Message containing reason for failure of pre flight check or order add</returns>
        bool TrySubmitOrder(Order order, IOrderEvent callback, out string message);
        
        /// <summary>
        /// Submits an order to the specific trading destination
        /// </summary>
        /// <param name="order"></param>
        /// <param name="callback"></param>
        /// <param name="dest"></param>
        /// <param name="message"></param>
        /// <returns>Message containing reason for failure of pre flight check or order add</returns>
        bool TrySubmitOrder(Order order, IOrderEvent callback, Exchanges.Destinations dest, out string message);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="order"></param>
        /// <param name="newClientOrderId"></param>
        /// <param name="newPrice"></param>
        /// <param name="newQuantity"></param>
        /// <param name="message"></param>
        /// <returns>Message containing reason for failure of pre flight check or order update</returns>
        bool TryReplaceOrder(Order order, out string message, decimal newPrice = 0m, uint newQuantity = 0);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="order"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        bool TryCancelOrder(Order order, out string message);
        
        bool TryGetOrder(string clientOrderId, out Order order);

    }
}
